A texture used for rendering, hosted on GPU. More...
Public Member Functions | |
Texture () | |
virtual | ~Texture () |
virtual void | setResourcePath (const nkMemory::StringView &path) override |
ResourceCpuDataDescriptor * | getCpuData () const |
bool | isFromFile () const |
bool | isGammaCorrected () const |
bool | isBackBufferTex () const |
TEX_TYPE | getTexType () const |
TEX_RENDER_FLAG | getRenderFlag () const |
unsigned int | getNeededMipsForSize () const |
virtual int | getWidth () const =0 |
virtual int | getHeight () const =0 |
virtual int | getDepthOrArraySize () const =0 |
virtual unsigned int | getMipLevels () const =0 |
virtual FORMAT | getTextureFormat () const =0 |
virtual CPU_ACCESS_FLAG | getCpuAccessRights () const =0 |
virtual USAGE | getTextureUsage () const =0 |
virtual BIND_FLAG | getTextureBinding () const =0 |
virtual RESOURCE_MISC_FLAG | getMiscFlag () const =0 |
virtual unsigned int | getSampleCount () const =0 |
virtual unsigned int | getSampleQuality () const =0 |
virtual bool | getAutoMipGeneration () const =0 |
void | setCpuData (const ResourceCpuDataDescriptor &data) |
void | setBackBufferTex (bool value) |
void | setFromImage (const nkImages::ImageView &image) |
virtual void | freeCpuData (bool freeDataPtr) |
virtual void | setGammaCorrected (bool value) |
virtual void | setWidth (unsigned int width)=0 |
virtual void | setHeight (unsigned int height)=0 |
virtual void | setDepthOrArraySize (unsigned int value)=0 |
virtual void | setMipLevels (unsigned int value)=0 |
virtual void | setTextureFormat (FORMAT format)=0 |
virtual void | setCpuAccessRights (CPU_ACCESS_FLAG rights)=0 |
virtual void | setTextureUsage (USAGE usage)=0 |
virtual void | setTextureBinding (BIND_FLAG binding)=0 |
virtual void | setAutoMipGeneration (bool value)=0 |
virtual void | copyParams (const Texture &other)=0 |
void | setTextureFormatFromString (const nkMemory::StringView &str) |
virtual void | prepareAsTexture2d () |
virtual void | prepareAsCubemap () |
virtual void | prepareAsTexture3d () |
virtual void | setRenderFlag (TEX_RENDER_FLAG value) |
virtual bool | preLoadFromFile ()=0 |
nkImages::Image | convertToImage (int mip, int sliceOrArrayIndex) |
virtual MapResult | map (const MapRequestDescriptor &requestDesc)=0 |
virtual void | unmap (const UnmapRequestDescriptor &requestDesc)=0 |
virtual void | gpuCopyFrom (Texture &other, const ResourceGpuCopyDescriptor &descriptor)=0 |
virtual void | exportClassToTree (nkExport::Node *rootNode) override |
virtual void | importClassFromTree (nkExport::Node *rootNode) override |
![]() | |
ShaderResource () | |
~ShaderResource () | |
virtual void | activate (SHADER_TYPE shaderStage, unsigned int slot)=0 |
![]() | |
Resource () | |
Resource (const nkMemory::StringView &path) | |
virtual | ~Resource () |
virtual bool | load ()=0 |
virtual void | unload ()=0 |
bool | isReadyForRendering () const |
bool | isUnloaded () const |
RESOURCE_LOAD_STATE | getLoadState () const |
nkMemory::StringView | getResourcePath () const |
RESOURCE_TYPE | getResourceTypeName () const |
nkMemory::StringView | getResourceName () const |
bool | getHidden () const |
void | setResourceName (const nkMemory::StringView &name) |
void | setHidden (bool value) |
![]() | |
Exportable () | |
virtual | ~Exportable () |
A texture used for rendering, hosted on GPU.
nkGraphics::Texture::Texture | ( | ) |
Constructor.
|
virtual |
Destructor.
|
overridevirtual |
See Resource::setResourcePath().
Reimplemented from nkGraphics::Resource.
ResourceCpuDataDescriptor* nkGraphics::Texture::getCpuData | ( | ) | const |
bool nkGraphics::Texture::isFromFile | ( | ) | const |
bool nkGraphics::Texture::isGammaCorrected | ( | ) | const |
bool nkGraphics::Texture::isBackBufferTex | ( | ) | const |
TEX_TYPE nkGraphics::Texture::getTexType | ( | ) | const |
TEX_RENDER_FLAG nkGraphics::Texture::getRenderFlag | ( | ) | const |
unsigned int nkGraphics::Texture::getNeededMipsForSize | ( | ) | const |
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |
|
pure virtual |
void nkGraphics::Texture::setCpuData | ( | const ResourceCpuDataDescriptor & | data | ) |
Sets the CPU data from which the texture should load when the load() method is called. Data needs to be formatted for the format specified for the texture.
If multiple sub-resources are needed but left unspecified (_subresources member left empty), their location and size will be automatically determined. In such case, it is expected that they fit the DirectX ordering :
To give an idea of what is expected, the data for a 2D 2x2x6 texture array would be in this order :
Tex0 Mip0, Tex0 Mip1, Tex1 Mip0, Tex1 Mip1...
In case the sub resources are specified within the provided descriptor, the data description is entirely left to the user. This means that if there are holes in the description, they won't be filled automatically.
data | The texture data to feed from the cpu to the texture. |
void nkGraphics::Texture::setBackBufferTex | ( | bool | value | ) |
value | If the texture is the back buffer, aka the final texture, of a RenderContext. |
void nkGraphics::Texture::setFromImage | ( | const nkImages::ImageView & | image | ) |
Sets the texture to load from a given pre-decoded image. This will translate all required metadata and data to be interpreted by the texture during loading.
image | The image to use as input data. |
|
virtual |
Frees the cpu data attached to the texture, possibly also freeing the memory given. This function has to be called after the load method has been called, for the process to know when the data can be fred.
freeDataPtr | If the data pointer provided should be freed also. |
|
virtual |
value | If the texture should be gamma corrected (true) or not (false). |
|
pure virtual |
width | The width of the texture, in pixels. |
|
pure virtual |
height | The height of the texture, in pixels. |
|
pure virtual |
value | The depth or array size of the texture, in pixels / slices. |
|
pure virtual |
value | The number of mips wanted for the texture. Can be 0 to mean that all mips should be used. |
|
pure virtual |
format | The format to assign to the texture. |
|
pure virtual |
rights | The cpu access flag wanted. |
|
pure virtual |
usage | The texture usage. |
|
pure virtual |
binding | The binding flag to use. Can be or'ed. |
|
pure virtual |
value | If the missing mips should automatically be generated upon load (true) or not (false). |
|
pure virtual |
Copies the decription parameters (width, height, format...) from another texture.
other | The texture to copy the information from. |
void nkGraphics::Texture::setTextureFormatFromString | ( | const nkMemory::StringView & | str | ) |
str | The string defining the format to use. StructToString will be used for translation. |
|
virtual |
Prepares the texture as a 2d texture. Should be used to change the internal texture type, impacting the way the texture will be loaded.
|
virtual |
Prepares the texture as a cubemap. Should be used to change the internal texture type, impacting the way the texture will be loaded.
|
virtual |
Prepares the texture as a 3d texture. Should be used to change the internal texture type, impacting the way the texture will be loaded.
|
virtual |
Allows to change the render flag of the texture. It needs to be called for texture that will need to be used as targets.
value | The flag to set. |
|
pure virtual |
If the texture comes from an external file, this function can be called to load the file into memory before using the texture. This function is isolated enough that it can be called off-thread (be sure not to change the texture in main thread during this process).
nkImages::Image nkGraphics::Texture::convertToImage | ( | int | mip, |
int | sliceOrArrayIndex | ||
) |
Allows to access the data of a texture in a practical way, through an image.
mip | The mip level from which the data should be accessed. |
sliceOrArrayIndex | The slice, or index in the array, to take the memory from. |
|
pure virtual |
Maps the texture memory for CPU interaction. Be sure to select the smallest map type needed, as a map operation can cause a flush in the rendering pipeline.
requestDesc | The map request description. |
|
pure virtual |
Unmap the texture memory. This needs to be called the earliest possible after a map operation. This operation will potentially commit the changes made in mapped data, to the GPU.
requestDesc | The unmap request. |
|
pure virtual |
Copies memory from another texture, in the GPU context.
other | The texture to copy the data from. |
descriptor | The description of the data to copy. |
|
overridevirtual |
Basic exporting capabilities.
rootNode | The tree to export to. |
Implements nkExport::Exportable.
|
overridevirtual |
Basic importing capabilities.
rootNode | The tree to import from. |
Implements nkExport::Exportable.